package converter

import (
	"fmt"
	"math"
	"reflect"
	"strconv"
)

func ConverterTest() {
	a := 12
	//int 转换float64
	area(float64(a))

	i := 7275
	//数字转换字符串
	sn := strconv.Itoa(i)
	fmt.Println(sn)

	s2 := "20"
	//字符串转数字
	i2, err := strconv.Atoi(s2)
	if err != nil {
		panic(err)
	}
	fmt.Println(i2, reflect.TypeOf(i2))
}

func area(r float64) {
	s := math.Pi * math.Pow(r, 2)
	fmt.Println(s)
}

func ParseDemo() {
	s1 := "1"
	//字符串转为bool
	//1:true,0:false
	b1, _ := strconv.ParseBool(s1)
	fmt.Println(b1, reflect.TypeOf(b1))

	s2 := "12"
	//返回的是int64类型的数据
	i, _ := strconv.ParseInt(s2, 10, 64)
	//12 int64
	fmt.Println(i, reflect.TypeOf(i))
}
